﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Crank.Core
{
    public class Token
    {
        public string Text { get; protected set; }
        public TokenType Type { get; protected set; }

        public Token(string text, TokenType type)
        {
            Text = text;
            Type = type;
        }

        public static readonly Token EOF = new Token(String.Empty, TokenType.EOF);
        public static readonly Token NULL = new Token(String.Empty, TokenType.NULL);
        public static readonly Token UNKNOWN = new Token(String.Empty, TokenType.Unknown);

        public override string ToString()
        {
            return String.Format( "TOKEN {0}: {1}", Type.ToString(), Text);
        }


        public bool Is(TokenType type)
        {
            return Type == type;
        }
    }

    public enum TokenType
    {
        NULL,
        Unknown,
        EOF,
        Identifier,
        Number,
        Operator,
        OpenBracket,
        CloseBracket,
        OpenBrace,
        CloseBrace,
        Comma,
        HasArrow,
        SpecifityAdapter,
        KeyAdapter,
        PreprocessorInstruction
    }
}
